package com.example.mrzhou.lvmm.view.fragment.tm;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.example.mrzhou.lvmm.R;
import com.example.mrzhou.lvmm.commom.base.BaseFragment;
import com.example.mrzhou.lvmm.commom.utils.FragmentViewPagerUtils;
import com.example.mrzhou.lvmm.entity.tm.TMSendMsg;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * A simple {@link Fragment} subclass.
 */
public class TMFragment extends BaseFragment {


    @BindView(R.id.tab_tm)
    TabLayout tabTm;
    @BindView(R.id.tv_tm_city)
    TextView tvTmCity;
    @BindView(R.id.vp_tm)
    ViewPager vpTm;

    public static final String[] TITLE_TM = {"周爆款", "限时抢", "清仓价"};
    private List<Fragment> fragments = new ArrayList<>();

    public TMFragment() {
        // Required empty public constructor
    }

    public static TMFragment newInstance() {

        Bundle args = new Bundle();

        TMFragment fragment = new TMFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_tm;
    }

    @Override
    protected void initView(View view) {
        ButterKnife.bind(this, view);
        initData();

    }

    @Override
    protected void initData() {
//        for (int i = 0; i < TITLE_TM.length; i++) {
//            fragments.add(TMSampleFragment.newInstance());
//        }
        fragments.add(TMSampleFragment.newInstance(new TMSendMsg(0, "api.com.groupbuy.getWeekHotCollections", "1477723294600", "1d929d6e2fd6ce132f72112ab8eac088", "", "")));
        fragments.add(TMSampleFragment.newInstance(new TMSendMsg(1, "api.com.groupbuy.getSeckillProductsByMark", "1477723294610", "01a1447757008f71dcb12d4dd6dc1c8a", "MIAOSHA", "1")));
        fragments.add(TMSampleFragment.newInstance(new TMSendMsg(2, "api.com.groupbuy.getGroupbuyListByProductMark", "1477723294618", "f1d2d937f9d24354c5c239566476aecd", "WEIPIN", "2")));
        FragmentViewPagerUtils utils = new FragmentViewPagerUtils();
        utils.fragmentVpUtils(fragments, TITLE_TM, vpTm, tabTm, getChildFragmentManager());
    }

    @OnClick(R.id.tv_tm_city)
    public void onClick() {
    }
}
